home *** CD-ROM | disk | FTP | other *** search
- OPT PREPROCESS
-
- MODULE 'feelin','libraries/feelin','a4'
-
- PROC main()
- DEF c,w,
- cc:PTR TO feelinClass
-
- sys_SGlob()
-
- IF feelinbase := OpenLibrary('feelin.library',FV_VERSION)
- /*
- Create the new custom class with a call to F_CreateClass().
-
- This function returns a feelinClass structure. You must use class.id as ID
- to create instance of your custom class. This ID is unique and made by
- F_CreateClass() when ID is NIL.
- */
- IF cc := F_CreateClassA([FA_SuperID, FC_Area,
- FA_Dispatcher, {myDispatcher},
- NIL])
-
- c := ClientObject,
- FA_Client_Title, 'Class1',
- FA_Client_Version, '$VER: Class1 1.00 (03-08-02)',
- FA_Client_Copyright, '©2002, Olivier Laviale',
- FA_Client_Author, 'Olivier Laviale (lotan9@aol.com)',
- FA_Client_Description, 'Demonstrate the use of custom classes.',
- FA_Client_Base, 'CLASS1',
-
- Child, w := WindowObject,
- FA_ID, "MAIN",
- FA_Window_Title, 'A Simple Custom Class',
-
- Child, VGroup,
- Child, F_NewObjA(cc.id,[TextFrame, TextBack, FA_Inner,[4,2,4,2]:CHAR, NIL]),
- End,
- End,
- End
-
- IF c
- F_DoA(w,FM_Notify,[FA_Window_CloseRequest,TRUE, c,2,FM_Client_ReturnID,FV_Client_Quit])
- F_Set(w,FA_Window_Open,TRUE)
-
- F_DoA(c,FM_Client_Run,NIL)
-
- F_DisposeObj(c)
- ENDIF
-
- F_RemoveClass(cc)
- ELSE
- WriteF('Unable to create custom class\n')
- ENDIF
-
- CloseLibrary(feelinbase)
- ELSE
- WriteF('Unable to open feelin.library\n')
- ENDIF
- ENDPROC
-
- /*
- Here is the beginning of our simple new class...
-
- This is an example for the simplest possible Feelin class. It's just
- some kind of custom image and supports only two methods: FM_AskMinMax
- and FM_Draw.
-
- This class is realy simple and do not requires any instance data.
- */
-
- PROC myDispatcher(cl=A2:PTR TO feelinClass,obj=A0:PTR TO feelinObject,method=D0,args=A1:PTR TO LONG)
- /*
- Here comes the dispatcher for our custom class. We only need to care
- about FM_AskMinMax and FM_Draw in this simple case. Unknown/unused
- methods are passed to the superclass immediately.
- */
- sys_RGlob()
-
- SELECT method
- CASE FM_AskMinMax ; myAskMinMax(cl,obj)
- CASE FM_Draw ; myDraw(cl,obj,args)
- DEFAULT ; RETURN F_SuperDoA(cl,obj,method,args)
- ENDSELECT
- ENDPROC
- PROC myAskMinMax(cl,obj:PTR TO feelinObject)
- /*
- FM_AskMinMax will be called before the window is opened and before
- layout takes place. We need to tell Feelin the minimum and maximum size
- of our object.
- */
-
- _minw(obj) += 100 ; _maxw(obj) := 500
- _minh(obj) += 40 ; _maxh(obj) := 300
-
- F_SuperDoA(cl,obj,FM_AskMinMax,NIL)
- ENDPROC
- PROC myDraw(cl,obj:PTR TO feelinObject,d:PTR TO FS_Draw)
- DEF i,c,rp,x1,y1,x2,y2
-
- /*
- let our superclass draw itself first, Area class would e.g. draw the
- frame and clear the whole region. What it does exactly depends on
- flags.
- */
-
- F_SuperDoA(cl,obj,FM_Draw,d)
-
- -> Ok, everything ready to render...
-
- rp := _rp(obj)
- x1 := _mx(obj) ; x2 := _mx2(obj)
- y1 := _my(obj) ; y2 := _my2(obj)
- c := FV_Pen_Shine
-
- FOR i := x1 TO x2 STEP 5
- _APen(_pen(obj,c))
- _Move(x1,y2); _Draw(i,y1)
- _Move(x2,y2); _Draw(i,y1)
-
- INC c ; IF c = FV_Pen_Highlight THEN c := FV_Pen_Shine
- ENDFOR
- ENDPROC
-